#ifndef _DKGL_FONT_H_
#define _DKGL_FONT_H_

#include "dkglPreRequest.h"
#include "dkglViewport.h"
#include "dkglColor.h"
#include <string>
#include <map>
//#include "stdio.h"

#define g_FontMgr		FontManager::GetSingleton()
#define g_FontMgrPtr	FontManager::GetSingletonPtr()

namespace DKGL
{

class FontManager;

class Font
{
private:
	Font()
	{ mColor[0] = mColor[1] = mColor[2] = 1.0f;};

	GLuint	base;					// Display list number of first character
    int		mCharWidths[256];		// Width of each character in pixels
    int		mCharHeight;			// Height of characters 
	char	mFriendlyName[64];		//user define
	GLfloat mColor[3];
friend class FontManager;
};

class FontManager : public Singleton<FontManager>
{
public:
	FontManager(HDC);
	~FontManager();

	
	bool addNewFont(const std::string& font_name, HDC, const char *typeface = NULL,
		int height = 20, FONT_TYPE = FT_NORMAL ,DWORD  italic = FALSE);
	
	void begin(const Viewport&);
	void printf(const std::string& msg,  int x, int y, MSG_ALIGNMENT = MA_ALIGN2LEFT,
		const std::string& font_name = "Default");
	//void printf(const std::string& font_name, int x, int y, MSG_ALIGNMENT, const char *format, ...);
	void end();

	void setFontColor(const std::string& font_name, float r, float g, float b);
	void setFontColor(const std::string& font_name, const Colorf&);

private:
	FontManager(){};
	std::map<std::string, Font*> mFont;
	//Font *mFont[MAX_FONT];

	Font	*_createFont(HDC hdc, const char *typeface, int height, int weight, DWORD italic);
	void	_destroyFont(Font *font);
	void	_putsFont(Font *font, const char *s);
};
}
#endif